<template>
	<view class="detail-container">
		<!-- 加载状态 -->
		<view v-if="loading" class="loading-container">
			<uni-load-more status="loading"></uni-load-more>
		</view>
		
		<!-- 比赛详情内容 -->
		<view v-else-if="matchDetail" class="detail-content">
			<!-- 头部信息卡片 -->
			<view class="competition-header-card">
				<view class="competition-info">
					<text class="competition-title">{{ matchDetail ? matchDetail.title : '比赛详情' }}</text>
					<view class="competition-stats">
						<view class="stat-item">
							<text class="stat-number">{{ totalTimeSlots }}</text>
							<text class="stat-label">场次</text>
						</view>
						<view class="stat-divider"></view>
						<view class="stat-item">
							<text class="stat-number">{{ totalApplications }}</text>
							<text class="stat-label">报名</text>
						</view>
					</view>
				</view>
				
				<view class="header-actions">
					<view v-if="isMatchPublisher" class="action-btn primary" @click="createSchedule">
						<text class="action-icon">📅</text>
						<text class="action-text">创建日程</text>
					</view>
				</view>
			</view>

			<!-- 标签栏 -->
			<view class="tab-switch">
				<view 
					class="tab-item" 
					:class="{ active: currentTab === 'detail' }"
					@click="switchTab('detail')"
				>
					<text class="tab-icon">ℹ️</text>
					<text class="tab-text">比赛详情</text>
				</view>
				<view 
					class="tab-item" 
					:class="{ active: currentTab === 'schedule' }"
					@click="switchTab('schedule')"
				>
					<text class="tab-icon">📋</text>
					<text class="tab-text">比赛日程</text>
				</view>
			</view>
			
			<!-- 比赛详情标签页 -->
			<view v-if="currentTab === 'detail'" class="detail-tab">
				<!-- 比赛头部信息 -->
				<view class="match-header">
					<view class="title-section">
						<text class="match-title">{{ matchDetail.title }}</text>
						<view class="match-status" :class="'status-' + matchDetail.status">
							{{ getStatusText(matchDetail.status) }}
						</view>
					</view>
					
					<view class="organizer-section">
						<view class="organizer-info">
							<uni-icons type="person-filled" size="16" color="#007aff"></uni-icons>
							<text class="organizer-text">组织者：{{ matchDetail.organizer_info.nickname }}</text>
						</view>
						<view class="contact-info" v-if="matchDetail.organizer_info.phone">
							<uni-icons type="phone" size="16" color="#007aff"></uni-icons>
							<text class="contact-text">{{ matchDetail.organizer_info.phone }}</text>
						</view>
					</view>
				</view>
				
				<!-- 基本信息卡片 -->
				<view class="info-card">
					<view class="card-title">
						<uni-icons type="info" size="18" color="#007aff"></uni-icons>
						<text class="title-text">基本信息</text>
					</view>
					
					<view class="info-grid">
						<view class="info-item">
							<text class="info-label">参赛组别</text>
							<text class="info-value">{{ matchDetail.age_groups || '未设置' }}</text>
						</view>
						
						<view class="info-item">
							<text class="info-label">比赛级别</text>
							<text class="info-value">{{ matchDetail.level }}</text>
						</view>
						
						<view class="info-item">
							<text class="info-label">比赛赛制</text>
							<text class="info-value">{{ formatMatchFormat(matchDetail.match_format) }}</text>
						</view>
						
						<view class="info-item">
							<text class="info-label">比赛时间</text>
							<text class="info-value">{{ formatDateRange(matchDetail.start_date, matchDetail.end_date) }}</text>
						</view>
						
						<view class="info-item">
							<text class="info-label">比赛地区</text>
							<text class="info-value">{{ matchDetail.location }}</text>
						</view>
						
						<view class="info-item">
							<text class="info-label">报名截止</text>
							<text class="info-value">{{ formatDate(matchDetail.registration_deadline) }}</text>
						</view>
					</view>
				</view>
				
				<!-- 比赛描述 -->
				<view v-if="matchDetail.description" class="description-card">
					<view class="card-title">
						<uni-icons type="compose" size="18" color="#007aff"></uni-icons>
						<text class="title-text">比赛介绍</text>
					</view>
					<view class="description-content">
						<text class="description-text">{{ matchDetail.description }}</text>
					</view>
				</view>
				
				<!-- 裁判需求 -->
				<view v-if="matchDetail.referee_positions && matchDetail.referee_positions.length > 0" class="referee-card">
					<view class="card-title">
						<uni-icons type="staff" size="18" color="#007aff"></uni-icons>
						<text class="title-text">裁判需求</text>
					</view>
					
					<view class="referee-list">
						<view 
							v-for="(position, index) in matchDetail.referee_positions" 
							:key="index" 
							class="referee-item"
						>
							<view class="position-info">
								<text class="position-name">{{ position.position }}</text>
								<text class="position-count">需要{{ position.count }}名</text>
							</view>
							<view v-if="position.requirements" class="position-requirements">
								<text class="requirements-text">要求：{{ position.requirements }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<!-- 比赛日程标签页 -->
			<view v-else-if="currentTab === 'schedule'" class="ui-test-container">

				<view v-if="loadingSchedule" class="loading-container">
					<uni-load-more status="loading"></uni-load-more>
				</view>

				<!-- 空状态 -->
				<view v-else-if="scheduleList.length === 0" class="empty-state">
					<text class="empty-icon">📅</text>
					<text class="empty-title">暂无比赛日程</text>
					<text class="empty-subtitle">点击上方按钮创建比赛日程</text>
				</view>

				<!-- 比赛日程列表 -->
				<view v-else class="schedule-list">
					<view 
						v-for="(schedule, scheduleIndex) in scheduleList" 
						:key="schedule._id"
						class="schedule-card"
						:class="{ 'schedule-completed': schedule.computed_status === 'completed' }"
					>
						<!-- 日程头部 -->
						<view class="schedule-header">
							<view class="date-info">
								<view class="date-main"
									:class="{ 'date-completed': schedule.computed_status === 'completed' }"
								>
									<text class="date-number">{{ getDateDay(schedule.date) }}</text>
									<text class="date-month">{{ getDateMonth(schedule.date) }}</text>
									<!-- 已结束标签 -->
									<view v-if="schedule.computed_status === 'completed'" class="schedule-completed-tag">已结束</view>
								</view>
								<view class="date-details">
									<text class="weekday">{{ getWeekday(schedule.date) }}</text>
									<view class="venue-info">
										<text class="venue-icon">📍</text>
										<text class="venue-text">{{ schedule.venue }}</text>
									</view>
								</view>
							</view>
							
							<view class="schedule-summary">
								<view class="summary-item">
									<text class="summary-icon">🏆</text>
									<text class="summary-text">{{ schedule.time_slots ? schedule.time_slots.length : 0 }}</text>
								</view>
								<view class="summary-item">
									<text class="summary-icon">👤</text>
									<text class="summary-text">{{ getScheduleApplicationCount(schedule) }}</text>
								</view>
							</view>
							
							<view class="schedule-actions-wrapper">
								<!-- 新时段标记 -->
								<view v-if="schedule.has_new_slots" class="new-slots-badge">新时段</view>
								
								<view v-if="isMatchPublisher" class="schedule-actions">
									<view class="action-icon invite" @click.stop="inviteUsersForSchedule(schedule)">
										<text class="icon-text">邀请</text>
									</view>
									<view class="action-icon edit" @click.stop="editSchedule(schedule)">
										<text class="icon-text">✏️</text>
									</view>
									<view class="action-icon delete" @click.stop="deleteSchedule(schedule)">
										<text class="icon-text">🗑️</text>
									</view>
								</view>
							</view>
						</view>
						
						<!-- 比赛时段列表 -->
						<view class="time-slots-container">
							<view 
								v-for="(slot, slotIndex) in schedule.time_slots" 
								:key="slot.slot_id"
															class="time-slot-wrapper"
							:class="{ 'slot-finalized': isSlotSelectionFinalized(slot) }"
							@click="viewSlotDetail(schedule, slot, slotIndex)"
							>
								<!-- 左侧：时间和场地 -->
								<view class="left-info">
									<view class="time-info">
										<text class="time-text">{{ slot.start_time }}-{{ slot.end_time }}</text>
									</view>
									<view class="field-info">
										<text class="field-icon">📍</text>
										<text class="field-text">{{ slot.field }}</text>
									</view>
								</view>
								
								<!-- 分隔线 -->
								<view class="divider-line"></view>
								
								<!-- 右侧：比赛详情 -->
								<view class="right-content">
									<!-- 对阵信息 -->
									<view class="match-info">
										<view class="team-card home-team-card">
											<text class="team-label">主</text>
											<text class="team-name">{{ slot.home_team }}</text>
										</view>
										<view class="team-card away-team-card">
											<text class="team-label">客</text>
											<text class="team-name">{{ slot.away_team }}</text>
										</view>
									</view>
									
									<!-- 组别和报名按钮 -->
									<view class="bottom-row">
										<view class="category-badge">{{ slot.category }}</view>
										<view 
											class="apply-btn" 
											:class="{
												'applied': isUserAppliedForSlot(slot) && !isSlotSelectionFinalized(slot),
												'available': !isUserAppliedForSlot(slot) && !isSlotSelectionFinalized(slot),
												'finalized': isSlotSelectionFinalized(slot)
											}" 
											@click.stop="applyForSlotReferee(schedule, slot, slotIndex)"
										>
											<text class="apply-icon">{{ 
												isSlotSelectionFinalized(slot) ? '🔒' : 
												isUserAppliedForSlot(slot) ? '✓' : '+' 
											}}</text>
											<text class="apply-text">{{ 
												isSlotSelectionFinalized(slot) ? '已完成选派' : 
												isUserAppliedForSlot(slot) ? '已报名' : '报名' 
											}}</text>
										</view>
									</view>
									
									<!-- 意向岗位信息 -->
									<view v-if="isUserAppliedForSlot(slot) && getUserPreferredPositions(slot).length > 0" class="preferred-positions">
										<text class="preferred-icon">🎯</text>
										<text class="preferred-text">意向岗位：{{ getUserPreferredPositions(slot).join('、') }}</text>
									</view>
									
									<!-- 备注信息 -->
									<view v-if="slot.notes || slot.referee_requirements" class="slot-notes">
										<text class="notes-icon">💡</text>
										<text class="notes-text">{{ slot.notes || formatRefereeRequirements(slot.referee_requirements) }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 错误状态 -->
		<view v-else class="error-container">
			<uni-icons type="info-filled" size="60" color="#ddd"></uni-icons>
			<text class="error-text">比赛信息加载失败</text>
			<button class="retry-btn" @click="loadMatchDetail">重新加载</button>
		</view>
		
		<!-- 底部操作栏 -->
		<view v-if="matchDetail && matchDetail.status === 'published' && currentTab === 'detail'" class="bottom-actions">
			<button class="share-bottom-btn" @click="showShareModal">
				<uni-icons type="share" size="16" color="#666"></uni-icons>
				<text class="share-bottom-text">分享</text>
			</button>
			<button class="apply-bottom-btn" @click="applyReferee">赛程与裁判报名</button>
		</view>
		
		<!-- 职位选择弹窗 -->
		<view v-if="showPositionModal" class="position-modal-overlay" @click="closePositionModal">
			<view class="position-modal" @click.stop>
				<view class="modal-header">
					<text class="modal-title">选择意向岗位</text>
					<view class="close-btn" @click="closePositionModal">✕</view>
				</view>
				

				<view class="modal-content">
					<view class="position-tip">
						<text class="tip-text">💡 系统将自动为您报名所有需求岗位，您可以选择意向岗位供审核参考</text>
					</view>
					
					<!-- 职位列表 -->
					<view class="position-simple-list">
						<view 
							v-for="(position, index) in modalPositions" 
							:key="position.key"
							class="position-simple-item"
							:class="{ 
								'applied': modalUserAppliedPositions.includes(position.key),
								'selected': selectedPositions.includes(position.key)
							}"
							@click="togglePositionSelection(position.key)"
						>
							<view class="position-content">
								<text class="position-text">{{ position.name }}：{{ position.count }}</text>
								<view v-if="modalUserAppliedPositions.includes(position.key)" class="applied-badge">
									<text class="applied-badge-text">{{ getPositionStatusText(position.key) }}</text>
								</view>
							</view>
						</view>
					</view>
					
					<!-- 统一手机号输入 -->
					<view class="phone-section">
						<view class="phone-label-row">
							<text class="phone-label">手机号码</text>
						</view>
						<input 
							class="phone-unified-input" 
							v-model="commonPhoneNumber"
							placeholder="请输入联系方式" 
							maxlength="11"
							type="number"
						/>
					</view>
					
					<!-- 确认按钮 -->
					<view class="confirm-section">
						<button 
							class="confirm-apply-btn"
							@click="confirmBatchApply"
							:disabled="selectedPositions.length === 0 || !commonPhoneNumber || !validatePhoneNumber(commonPhoneNumber)"
						>
							确认报名
						</button>
					</view>
				</view>
				
				<view class="modal-footer">
					<button class="close-modal-btn" @click="closePositionModal">关闭</button>
				</view>
			</view>
		</view>
		
		<!-- 分享弹窗 -->
		<share-modal 
			:show="showShareModalFlag"
			:matchData="matchDetail"
			@close="closeShareModal"
			@share="onShareToMiniProgram"
			@triggerShare="onTriggerShare"
			@shareSuccess="onShareSuccess"
		></share-modal>
	</view>
</template>

<script>
import ShareModal from '@/components/share-modal.vue'

export default {
	components: {
		ShareModal
	},
	
	data() {
		return {
			loading: true,
			loadingSchedule: false,
			matchId: '',
			matchDetail: null,
			scheduleList: [],
			currentTab: 'detail',
			
			// 用户报名状态
			userApplications: {},
			
			// 职位配置
			positionConfig: [
				{ key: 'main_referee', name: '主裁判' },
				{ key: 'assistant_referee', name: '助理裁判' },
				{ key: 'fourth_official', name: '第四官员' },
				{ key: 'referee_supervisor', name: '裁判监督' }
			],
			
			// 职位选择弹窗相关数据
			showPositionModal: false,
			modalSchedule: null,
			modalSlot: null,
			modalPositions: [],
			modalUserAppliedPositions: [],
			selectedPositions: [], // 当前选中要报名的职位
			commonPhoneNumber: '', // 统一的手机号输入
			
			// 分享功能相关数据
			showShareModalFlag: false,
			currentShareData: null,
			shareTitle: '',
			sharePath: '',
			shareImageUrl: ''
		}
	},
	
	computed: {
		// 判断当前用户是否为比赛发布者
		isMatchPublisher() {
			if (!this.matchDetail) return false
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) return false
			
			try {
				const userInfo = typeof userInfoStr === 'string' ? JSON.parse(userInfoStr) : userInfoStr
				console.log('当前用户ID:', userInfo._id || userInfo.userId)
				console.log('比赛发布者ID:', this.matchDetail.publisher_id)
				
				// 支持多种用户ID字段格式
				const currentUserId = userInfo._id || userInfo.userId
				return this.matchDetail.publisher_id === currentUserId
			} catch (error) {
				console.error('解析用户信息失败:', error)
				return false
			}
		},
		
		// 计算总时段数
		totalTimeSlots() {
			return this.scheduleList.reduce((total, schedule) => {
				return total + (schedule.time_slots ? schedule.time_slots.length : 0)
			}, 0)
		},
		
		// 计算总报名数
		totalApplications() {
			return this.scheduleList.reduce((total, schedule) => {
				if (!schedule.time_slots) return total
				return total + schedule.time_slots.reduce((slotTotal, slot) => {
					return slotTotal + (slot.applications ? slot.applications.filter(app => app.status !== 'cancelled').length : 0)
				}, 0)
			}, 0)
		}
	},
	
	onLoad(options) {
		if (options.id) {
			this.matchId = options.id
			// 立即加载比赛详情数据
			this.$nextTick(() => {
				console.log('nextTick中加载数据，matchId:', this.matchId)
				this.loadMatchDetail()
			})
		} else {
			this.handleError('缺少比赛ID参数')
		}
	},

	onReady() {
		// 页面初次渲染完成后加载数据
		console.log('onReady 触发，matchId:', this.matchId)
		if (this.matchId && !this.matchDetail) {
			console.log('开始加载比赛详情数据')
			this.loadMatchDetail()
		}
	},
	
	onPullDownRefresh() {
		if (this.currentTab === 'detail') {
			this.loadMatchDetail().then(() => {
				uni.stopPullDownRefresh()
			})
		} else if (this.currentTab === 'schedule') {
			this.loadScheduleList().then(() => {
				uni.stopPullDownRefresh()
			})
		}
	},
	
	// 微信小程序分享配置
	onShareAppMessage() {
		// 优先使用自定义的分享数据
		if (this.currentShareData) {
			return {
				title: this.currentShareData.title,
				path: this.currentShareData.path,
				imageUrl: this.currentShareData.imageUrl
			}
		}
		
		// 默认分享数据
		if (this.matchDetail) {
			return {
				title: this.matchDetail.title,
				desc: `${this.formatDateRange(this.matchDetail.start_date, this.matchDetail.end_date)} | ${this.matchDetail.location}`,
				path: `/packgeCompetition/competition/share-preview?id=${this.matchId}&from=share`,
				imageUrl: this.matchDetail.poster || ''
			}
		}
		return {}
	},
	
	methods: {
		// 加载比赛详情
		async loadMatchDetail() {
			this.loading = true
			try {
				const matchObject = uniCloud.importObject('match-object')
				const result = await matchObject.getMatchDetail(this.matchId)
				
				if (result.code === 0) {
					this.matchDetail = result.data
					console.log('比赛详情加载完成:', this.matchDetail)
					
					// 调试信息：检查用户身份
					const userInfoStr = uni.getStorageSync('userInfo')
					if (userInfoStr) {
						try {
							const userInfo = typeof userInfoStr === 'string' ? JSON.parse(userInfoStr) : userInfoStr
							console.log('当前用户信息:', userInfo)
							console.log('当前用户ID:', userInfo._id || userInfo.userId)
							console.log('比赛发布者ID:', this.matchDetail.publisher_id)
							console.log('是否为发布者:', this.isMatchPublisher)
						} catch (error) {
							console.error('解析用户信息失败:', error)
						}
					} else {
						console.log('未找到用户信息')
					}
				} else {
					this.handleError(result.message || '获取比赛详情失败')
				}
			} catch (error) {
				this.handleError('网络错误: ' + error.message)
			} finally {
				this.loading = false
			}
		},
		
		// 加载比赛日程
		async loadScheduleList() {
			this.loadingSchedule = true
			try {
				const scheduleObject = uniCloud.importObject('match-schedule-object')
				const result = await scheduleObject.getMatchSchedules(this.matchId)
				if (result.code === 0) {
					let scheduleList = result.data.list || []
					
					// 为每个日程计算状态
					scheduleList = scheduleList.map(schedule => {
						return {
							...schedule,
							computed_status: this.computeScheduleStatus(schedule),
							has_new_slots: this.hasNewSlots(schedule)
						}
					})
					
					// 应用智能排序
					this.scheduleList = this.sortScheduleList(scheduleList)
				} else {
					this.handleError(result.message || '获取比赛日程失败')
				}
			} catch (error) {
				this.handleError('网络错误: ' + error.message)
			} finally {
				this.loadingSchedule = false
			}
		},
		
		// 计算日程状态
		computeScheduleStatus(schedule) {
			if (!schedule.time_slots || schedule.time_slots.length === 0) {
				return 'empty'
			}
			
			// 检查是否所有时段都已完成（所有裁判监督都已评价完成）
			const allSlotsCompleted = this.isScheduleCompleted(schedule)
			if (allSlotsCompleted) {
				return 'completed'
			}
			
			// 检查是否有进行中的时段
			const hasInProgressSlots = this.hasInProgressSlots(schedule)
			if (hasInProgressSlots) {
				return 'in_progress'
			}
			
			// 检查日期是否已过
			const scheduleDate = new Date(schedule.date)
			const now = new Date()
			
			if (scheduleDate < now) {
				// 日期已过，但可能还有待处理的事项
				return 'past'
			} else {
				// 未来的日程
				return 'upcoming'
			}
		},
		
		// 判断日程是否已完成（所有时段的裁判监督都已评价完成）
		isScheduleCompleted(schedule) {
			if (!schedule.time_slots || schedule.time_slots.length === 0) {
				return false
			}
			
			// 简化判断：如果日程日期过了7天以上，且没有新活动，认为已完成
			const scheduleDate = new Date(schedule.date)
			const now = new Date()
			const daysPassed = (now - scheduleDate) / (1000 * 60 * 60 * 24)
			
			if (daysPassed > 7 && !this.hasNewSlots(schedule)) {
				return true
			}
			
			// 检查是否所有时段都没有新的报名活动
			const hasActiveApplications = schedule.time_slots.some(slot => {
				if (!slot.applications) return false
				return slot.applications.some(app => 
					app.status === 'pending' || app.status === 'selected'
				)
			})
			
			// 如果日期已过且没有活跃的申请，可能已完成
			if (daysPassed > 3 && !hasActiveApplications) {
				return true
			}
			
			return false
		},
		
		// 判断是否有进行中的时段
		hasInProgressSlots(schedule) {
			if (!schedule.time_slots || schedule.time_slots.length === 0) {
				return false
			}
			
			const scheduleDate = new Date(schedule.date)
			const now = new Date()
			
			// 如果是今天的日程，检查是否有时段正在进行
			if (scheduleDate.toDateString() === now.toDateString()) {
				return schedule.time_slots.some(slot => {
					const startTime = new Date(`${schedule.date} ${slot.start_time}`)
					const endTime = new Date(`${schedule.date} ${slot.end_time}`)
					return now >= startTime && now <= endTime
				})
			}
			
			// 如果有未处理的申请，也认为是进行中
			return schedule.time_slots.some(slot => {
				if (!slot.applications) return false
				return slot.applications.some(app => 
					app.status === 'pending' || app.status === 'selected'
				)
			})
		},
		
		// 检查是否有新时段
		hasNewSlots(schedule) {
			// 简化判断：检查最近更新时间
			if (schedule.update_time || schedule.create_time) {
				const updateTime = new Date(schedule.update_time || schedule.create_time)
				const now = new Date()
				const hoursPassed = (now - updateTime) / (1000 * 60 * 60)
				
				// 24小时内更新的认为是新的
				return hoursPassed < 24
			}
			
			return false
		},
		
		// 智能排序日程列表
		sortScheduleList(scheduleList) {
			return scheduleList.sort((a, b) => {
				// 第一优先级：有新时段的日程置顶
				const aHasNew = a.has_new_slots
				const bHasNew = b.has_new_slots
				
				if (aHasNew && !bHasNew) return -1
				if (!aHasNew && bHasNew) return 1
				
				// 第二优先级：按状态排序
				const statusWeight = {
					'upcoming': 5,     // 即将到来的
					'in_progress': 4,  // 进行中的
					'past': 3,         // 已过去的
					'completed': 2,    // 已完成的
					'empty': 1         // 空日程
				}
				
				const aWeight = statusWeight[a.computed_status] || 2
				const bWeight = statusWeight[b.computed_status] || 2
				
				if (aWeight !== bWeight) {
					return bWeight - aWeight // 降序，权重高的在前
				}
				
				// 第三优先级：按创建时间排序（新的在前）
				const aTime = new Date(a.create_time || a.update_time || a.date || 0)
				const bTime = new Date(b.create_time || b.update_time || b.date || 0)
				
				return bTime - aTime
			})
		},
		
		// 切换标签
		switchTab(tab) {
			this.currentTab = tab
			if (tab === 'schedule' && this.scheduleList.length === 0) {
				this.loadScheduleList()
			} else if (tab === 'detail' && !this.matchDetail) {
				this.loadMatchDetail()
			}
		},
		
		// 格式化日程日期（选派系统1.1.6样式）
		formatScheduleDate(dateString) {
			if (!dateString) return ''
			const date = new Date(dateString)
			const month = date.getMonth() + 1
			const day = date.getDate()
			return `${month}月${day}日`
		},
		
		// 获取星期几
		getWeekday(dateString) {
			if (!dateString) return ''
			const date = new Date(dateString)
			const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
			return weekdays[date.getDay()]
		},
		
		// 格式化裁判需求（选派系统1.1.6样式）
		formatRefereeNeeds(requirements) {
			if (!requirements || typeof requirements !== 'object') return '无建议'
			
			const needs = []
			const positionNames = {
				main_referee: '主裁判',
				assistant_referee: '助理裁判',
				fourth_official: '第四官员',
				referee_supervisor: '裁判监督'
			}
			
			Object.keys(requirements).forEach(key => {
				const count = requirements[key]
				if (count > 0) {
					const name = positionNames[key] || key
					needs.push(`${name}${count}名`)
				}
			})
			
			return needs.length > 0 ? `建议：${needs.join('、')}` : '无建议'
		},
		
		// 检查用户是否已报名该时段（返回报名的岗位数量）
		getUserAppliedPositionsCount(slot) {
			if (!slot.applications) return 0
			
			const userId = this.getCurrentUserId()
			if (!userId) return 0
			
			return slot.applications.filter(app => 
				app.user_id === userId && app.status !== 'cancelled'
			).length
		},
		
		// 检查用户是否已报名该时段（兼容旧方法）
		isUserAppliedForSlot(slot) {
			return this.getUserAppliedPositionsCount(slot) > 0
		},
		
		// 获取用户报名状态文本
		getUserApplicationStatusText(slot) {
			const appliedCount = this.getUserAppliedPositionsCount(slot)
			if (appliedCount === 0) {
				return '报名'
			} else if (appliedCount === 1) {
				return '已报名1个岗位'
			} else {
				return `已报名${appliedCount}个岗位`
			}
		},
		
		// 申请时段裁判（选派系统1.1.6样式）
		async applyForSlotReferee(schedule, slot, slotIndex) {
			if (!this.getCurrentUserId()) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					success: (res) => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}
					}
				})
				return
			}
			
			// 检查时段是否已完成最终选派确认
			if (this.isSlotSelectionFinalized(slot)) {
				uni.showModal({
					title: '无法报名',
					content: '该时段已完成最终选派确认，不再接受新的报名申请。',
					showCancel: false,
					confirmText: '知道了'
				})
				return
			}
			
			// 如果已经报名，显示报名详情
			if (this.isUserAppliedForSlot(slot)) {
				this.showApplicationDetail(schedule, slot)
				return
			}
			
			// 显示报名选择弹窗（支持多选）
			this.showApplicationModal(schedule, slot, slotIndex)
		},
		
		// 显示报名选择弹窗（支持多选）
		showApplicationModal(schedule, slot, slotIndex) {
			const positions = this.getRefereePositions(slot.referee_requirements)
			
			if (positions.length === 0) {
				uni.showToast({
					title: '该时段暂无裁判职位',
					icon: 'none'
				})
				return
			}
			
			// 获取用户已报名的职位
			const userId = this.getCurrentUserId()
			const userAppliedPositions = []
			if (slot.applications && userId) {
				slot.applications.forEach(app => {
					if (app.user_id === userId && app.status !== 'cancelled') {
						userAppliedPositions.push(app.position)
					}
				})
			}
			
			// 显示自定义弹窗
			this.showCustomPositionModal(schedule, slot, positions, userAppliedPositions)
		},
		
		// 显示自定义职位选择弹窗
		showCustomPositionModal(schedule, slot, positions, userAppliedPositions) {
			this.modalSchedule = schedule
			this.modalSlot = slot
			this.modalPositions = positions
			this.modalUserAppliedPositions = userAppliedPositions
			
			// 初始化选择状态
			this.selectedPositions = []
			this.commonPhoneNumber = ''
			
			this.showPositionModal = true
		},
		
		// 关闭职位选择弹窗
		closePositionModal() {
			this.showPositionModal = false
			this.modalSchedule = null
			this.modalSlot = null
			this.modalPositions = []
			this.modalUserAppliedPositions = []
			this.selectedPositions = []
			this.commonPhoneNumber = ''
		},
		
		// 切换职位选择状态
		togglePositionSelection(positionKey) {
			// 如果已经报名，不允许选择
			if (this.modalUserAppliedPositions && this.modalUserAppliedPositions.includes(positionKey)) {
				uni.showToast({
					title: '该职位已报名',
					icon: 'none'
				})
				return
			}
			
			// 确保 selectedPositions 数组存在
			if (!this.selectedPositions) {
				this.selectedPositions = []
			}
			
			const index = this.selectedPositions.indexOf(positionKey)
			if (index > -1) {
				// 取消选择
				this.selectedPositions.splice(index, 1)
			} else {
				// 添加选择
				this.selectedPositions.push(positionKey)
			}
		},
		

		

		
		// 获取岗位申请状态文本
		getPositionStatusText(positionKey) {
			if (!this.modalSlot || !this.modalSlot.applications) return '✓ 已报名'
			
			const userId = this.getCurrentUserId()
			if (!userId) return '✓ 已报名'
			
			// 找到该用户在该岗位的申请
			const application = this.modalSlot.applications.find(app => 
				app.user_id === userId && 
				app.position === positionKey && 
				app.status !== 'cancelled'
			)
			
			if (!application) return '✓ 已报名'
			
			// 根据状态返回不同的文本
			switch (application.status) {
				case 'pending':
					return '⏳ 待审核'
				case 'selected':
					return '✅ 已选派'
				case 'confirmed':
					return '🎯 已确认'
				case 'rejected':
					return '❌ 已拒绝'
				default:
					return '✓ 已报名'
			}
		},
		

		
		// 批量确认报名
		async confirmBatchApply() {
			if (!this.commonPhoneNumber || !this.validatePhoneNumber(this.commonPhoneNumber)) {
				uni.showToast({
					title: '请输入正确的手机号码',
					icon: 'none'
				})
				return
			}
			
			try {
				uni.showLoading({ title: '报名中...' })
				
				// 【新逻辑】获取所有需求岗位进行自动报名
				const allRequiredPositions = this.getRefereePositions(this.modalSlot.referee_requirements)
				const preferredPositions = this.selectedPositions || [] // 用户选择的意向岗位
				
				// 为所有需求岗位提交报名申请
				const promises = allRequiredPositions.map(position => {
					return this.submitSingleApplication(position.key, this.commonPhoneNumber, preferredPositions)
				})
				
				const results = await Promise.all(promises)
				
				// 检查结果
				const successCount = results.filter(result => result.success).length
				const failCount = results.length - successCount
				
				uni.hideLoading()
				
				if (successCount > 0) {
					// 先关闭弹窗
					this.closePositionModal()
					
					// 显示成功提示
					uni.showToast({
						title: `成功报名全部需求岗位${failCount > 0 ? `，${failCount}个失败` : ''}`,
						icon: 'success',
						duration: 2000
					})
					
					// 延迟重新加载数据，确保成功提示能显示
					setTimeout(() => {
						this.loadScheduleList()
					}, 500)
					
				} else {
					// 处理所有失败的情况，检查是否有特定的权限错误
					const failedResults = results.filter(result => !result.success)
					const hasPermissionError = failedResults.some(result => 
						result.result && (result.result.reason === 'not_certified' || result.result.reason === 'role_not_allowed')
					)
					
					if (hasPermissionError) {
						// 找到第一个权限错误并显示具体提示
						const permissionError = failedResults.find(result => 
							result.result && (result.result.reason === 'not_certified' || result.result.reason === 'role_not_allowed')
						)
						
						if (permissionError.result.reason === 'not_certified') {
							uni.showModal({
								title: '报名不成功',
								content: '您还未通过身份资质认证，请先申请资质认证',
								confirmText: '去认证',
								cancelText: '取消',
								success: (res) => {
									if (res.confirm) {
										// 关闭弹窗并跳转到资质认证申请页面
										this.closePositionModal()
										uni.navigateTo({
											url: '/packageMy/my/credential-upload'
										})
									}
								}
							})
						} else if (permissionError.result.reason === 'role_not_allowed') {
							uni.showModal({
								title: '报名不成功',
								content: '只有裁判员和裁判监督可以报名比赛选派',
								showCancel: false,
								confirmText: '我知道了',
								success: () => {
									this.closePositionModal()
								}
							})
						}
					} else {
						// 显示第一个具体的错误消息，如果没有则显示通用错误
						const firstError = failedResults[0]
						const errorMessage = (firstError.result && firstError.result.message) || '报名失败，请重试'
						uni.showToast({
							title: errorMessage,
							icon: 'none'
						})
					}
				}
			} catch (error) {
				uni.hideLoading()
				console.error('批量报名失败:', error)
				uni.showToast({
					title: '网络错误，请重试',
					icon: 'none'
				})
			}
		},
		
		// 提交单个职位申请
		async submitSingleApplication(positionKey, phoneNumber, preferredPositions = []) {
			try {
				const scheduleObject = uniCloud.importObject('match-schedule-object')
				const result = await scheduleObject.applyForSlotReferee({
					schedule_id: this.modalSchedule._id,
					slot_id: this.modalSlot.slot_id,
					position: positionKey,
					reason: '申请报名',
					contact_phone: phoneNumber,
					preferred_positions: preferredPositions, // 新增：意向岗位信息
					auto_apply_mode: true // 新增：自动报名模式标识
				})
				

				return { 
					success: result.code === 0, 
					result,
					position: positionKey
				}
			} catch (error) {
				console.error(`职位${positionKey}报名失败:`, error)
				return { 
					success: false, 
					error, 
					result: { message: '网络错误', code: -1 },
					position: positionKey
				}
			}
		},
		

		

		

		

		
		// 验证手机号格式
		validatePhoneNumber(phone) {
			if (!phone) return false
			const phoneRegex = /^1[3-9]\d{9}$/
			return phoneRegex.test(phone)
		},
		
		// 确认申请职位
		async confirmApplyForPosition(schedule, slot, positionKey, phoneNumber = '') {
			try {
				uni.showLoading({ title: '申请中...' })
				
				const scheduleObject = uniCloud.importObject('match-schedule-object')
				const result = await scheduleObject.applyForSlotReferee({
					schedule_id: schedule._id,
					slot_id: slot.slot_id,
					position: positionKey,
					reason: '申请报名',
					contact_phone: phoneNumber
				})
				
				uni.hideLoading()
				
				if (result.code === 0) {
					uni.showToast({
						title: '报名成功',
						icon: 'success'
					})
					
					// 重新加载日程数据
					this.loadScheduleList()
					
					// 如果弹窗打开，更新弹窗中的已报名状态
					if (this.showPositionModal && this.modalSlot) {
						const userId = this.getCurrentUserId()
						if (userId && !this.modalUserAppliedPositions.includes(positionKey)) {
							this.modalUserAppliedPositions.push(positionKey)
						}
					}
				} else {
					// 处理后端返回的权限错误，显示具体的错误提示
					if (result.reason === 'not_certified') {
						uni.showModal({
							title: '报名不成功',
							content: '您还未通过身份资质认证，请先申请资质认证',
							confirmText: '去认证',
							cancelText: '取消',
							success: (res) => {
								if (res.confirm) {
									// 跳转到资质认证申请页面
									uni.navigateTo({
										url: '/packageMy/my/credential-upload'
									})
								}
							}
						})
					} else if (result.reason === 'role_not_allowed') {
						uni.showModal({
							title: '报名不成功',
							content: '只有裁判员和裁判监督可以报名比赛选派',
							showCancel: false,
							confirmText: '我知道了'
						})
					} else {
						uni.showToast({
							title: result.message || '报名失败',
							icon: 'none'
						})
					}
				}
			} catch (error) {
				uni.hideLoading()
				console.error('报名失败:', error)
				uni.showToast({
					title: '网络错误，请稍后重试',
					icon: 'none'
				})
			}
		},
		
		// 显示申请详情（优化多岗位显示）
		showApplicationDetail(schedule, slot) {
			const userId = this.getCurrentUserId()
			const userApplications = slot.applications.filter(app => 
				app.user_id === userId && app.status !== 'cancelled'
			)
			
			if (userApplications.length === 0) return
			
			const positionNames = {
				main_referee: '主裁判',
				assistant_referee: '助理裁判',
				fourth_official: '第四官员',
				referee_supervisor: '裁判监督'
			}
			
			let content = '您在此时段的报名情况：\n\n'
			
			userApplications.forEach((app, index) => {
				const positionName = positionNames[app.position] || app.position
				const statusText = this.getApplicationStatusText(app.status)
				const statusIcon = this.getStatusIcon(app.status)
				content += `${index + 1}. ${positionName}：${statusIcon} ${statusText}\n`
			})
			
			content += `\n共报名 ${userApplications.length} 个岗位`
			
			uni.showModal({
				title: '我的报名详情',
				content: content,
				showCancel: false,
				confirmText: '知道了'
			})
		},
		

		
		// 获取状态图标
		getStatusIcon(status) {
			const iconMap = {
				'pending': '⏳',
				'selected': '✅',
				'confirmed': '🎯',
				'rejected': '❌',
				'cancelled': '🚫'
			}
			return iconMap[status] || '❓'
		},
		
		// 查看时段详情
		viewSlotDetail(schedule, slot, slotIndex) {
			// 可以在这里实现跳转到时段详情页面
			console.log('查看时段详情:', schedule, slot, slotIndex)
		},
		
		// 删除日程
		async deleteSchedule(schedule, scheduleIndex) {
			uni.showModal({
				title: '确认删除',
				content: `确定要删除${this.formatScheduleDate(schedule.date)}的比赛日程吗？`,
				success: async (res) => {
					if (res.confirm) {
						try {
							uni.showLoading({ title: '删除中...' })
							
							const scheduleObject = uniCloud.importObject('match-schedule-object')
							const result = await scheduleObject.deleteSchedule(schedule._id)
							
							uni.hideLoading()
							
							if (result.code === 0) {
								uni.showToast({
									title: '删除成功',
									icon: 'success'
								})
								// 重新加载日程列表
								this.loadScheduleList()
							} else {
								uni.showToast({
									title: result.message || '删除失败',
									icon: 'none'
								})
							}
						} catch (error) {
							uni.hideLoading()
							console.error('删除日程失败:', error)
							uni.showToast({
								title: '网络错误，请稍后重试',
								icon: 'none'
							})
						}
					}
				}
			})
		},
		
		// 查看比赛时段
		viewSession(session) {
			// 构造传递的数据
			const sessionData = {
				session_id: session.slot_id,
				match_id: this.matchId,
				series_id: this.matchId,
				series_title: this.matchDetail ? this.matchDetail.title : '',
				date: session.date,
				start_time: session.start_time,
				end_time: session.end_time,
				home_team: session.home_team,
				away_team: session.away_team,
				positions: session.referee_requirements || {}
			}
			
			uni.navigateTo({
				url: `/packageMy/my/application-list?data=${encodeURIComponent(JSON.stringify(sessionData))}`
			})
		},
		
		// 邀请用户（针对特定日程）
		inviteUsersForSchedule(schedule) {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					success: (res) => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}
					}
				})
				return
			}
			
			if (!this.isMatchPublisher) {
				this.handleError('只有比赛发布者才能邀请用户')
				return
			}
			
			uni.navigateTo({
				url: `/packgeCompetition/competition/invite-users?scheduleId=${schedule._id}&matchId=${this.matchId}&scheduleDate=${schedule.date}`
			})
		},
		
		// 创建比赛日程
		createSchedule() {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					success: (res) => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}
					}
				})
				return
			}
			
			if (!this.isMatchPublisher) {
				this.handleError('只有比赛发布者才能创建日程')
				return
			}
			
			uni.navigateTo({
				url: `/packgeCompetition/competition/create-schedule?matchId=${this.matchId}`
			})
		},
		
		// 编辑比赛日程
		editSchedule(schedule) {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					success: (res) => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}
					}
				})
				return
			}
			
			if (!this.isMatchPublisher) {
				this.handleError('只有比赛发布者才能编辑日程')
				return
			}
			
			const scheduleId = schedule._id
			if (!scheduleId) {
				this.handleError('日程ID不存在')
				return
			}
			
			uni.navigateTo({
				url: `/packgeCompetition/competition/create-schedule?matchId=${this.matchId}&mode=edit&scheduleId=${scheduleId}`
			})
		},
		
		// 获取日程的时段数量
		getScheduleSlotCount(schedule) {
			return schedule.time_slots ? schedule.time_slots.length : 0
		},
		
		// 获取日程的报名数量
		getScheduleApplicationCount(schedule) {
			if (!schedule.time_slots) return 0
			return schedule.time_slots.reduce((total, slot) => {
				return total + (slot.applications ? slot.applications.filter(app => app.status !== 'cancelled').length : 0)
			}, 0)
		},
		
		// 获取日期的日
		getDateDay(dateString) {
			if (!dateString) return ''
			const date = new Date(dateString)
			return date.getDate()
		},
		
		// 获取日期的月
		getDateMonth(dateString) {
			if (!dateString) return ''
			const date = new Date(dateString)
			const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
			return months[date.getMonth()]
		},
		
		// 获取裁判职位列表
		getRefereePositions(requirements) {
			if (!requirements || typeof requirements !== 'object') {
				return []
			}
			
			return this.positionConfig.filter(position => {
				const count = requirements[position.key]
				return count && count > 0
			}).map(position => ({
				...position,
				count: requirements[position.key]
			}))
		},
		
		// 获取职位申请数量
		getPositionApplicationCount(slot, positionKey) {
			if (!slot.applications) return 0
			return slot.applications.filter(app => 
				app.position === positionKey && app.status !== 'cancelled'
			).length
		},
		
		// 获取用户在该时段该职位的申请
		getUserApplication(slot, positionKey) {
			if (!slot.applications) return null
			
			const userId = this.getCurrentUserId()
			return slot.applications.find(app => 
				app.user_id === userId && 
				app.position === positionKey && 
				app.status !== 'cancelled'
			)
		},
		
		// 获取用户在该时段的意向岗位信息
		getUserPreferredPositions(slot) {
			if (!slot.applications) {
				return []
			}
			
			const userId = this.getCurrentUserId()
			if (!userId) {
				return []
			}
			
			// 查找用户的申请记录
			const userApplications = slot.applications.filter(app => 
				app.user_id === userId && app.status !== 'cancelled'
			)
			
			if (userApplications.length === 0) {
				return []
			}
			
			// 获取第一个申请的意向岗位信息（因为是自动报名，所有申请的意向岗位应该是一样的）
			const firstApplication = userApplications[0]
			
			if (!firstApplication.preferred_positions || firstApplication.preferred_positions.length === 0) {
				return []
			}
			
			// 将意向岗位key转换为显示名称
			const positionNames = {
				main_referee: '主裁判',
				assistant_referee: '助理裁判',
				fourth_official: '第四官员',
				referee_supervisor: '裁判监督'
			}
			
			return firstApplication.preferred_positions.map(key => 
				positionNames[key] || key
			)
		},
		
		// 获取当前用户ID
		getCurrentUserId() {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) return null
			
			try {
				const userInfo = typeof userInfoStr === 'string' ? JSON.parse(userInfoStr) : userInfoStr
				return userInfo._id || userInfo.userId
			} catch (error) {
				console.error('解析用户信息失败:', error)
				return null
			}
		},
		
		// 获取当前用户信息
		getCurrentUserInfo() {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) return null
			
			try {
				return typeof userInfoStr === 'string' ? JSON.parse(userInfoStr) : userInfoStr
			} catch (error) {
				console.error('解析用户信息失败:', error)
				return null
			}
		},
		
		// 获取申请状态文本
		getApplicationStatusText(status) {
			const statusMap = {
				'pending': '待审核',
				'selected': '已选派',
				'confirmed': '已确认',
				'rejected': '已拒绝',
				'cancelled': '已取消'
			}
			return statusMap[status] || status
		},
		
		// 获取申请状态样式类
		getApplicationStatusClass(status) {
			return `status-${status}`
		},
		
		// 申请做裁判
		applyReferee() {
			const userInfoStr = uni.getStorageSync('userInfo')
			if (!userInfoStr) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					success: (res) => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}
					}
				})
				return
			}
			
			// 直接跳转到比赛日程标签页
			this.switchTab('schedule')
			
			// 如果还没有加载日程数据，则加载
			if (this.scheduleList.length === 0) {
				this.loadScheduleList()
			}
		},
		
		// 提交裁判申请
		async submitRefereeApplication() {
			try {
				uni.showLoading({
					title: '提交申请中...'
				})
				
				const matchObject = uniCloud.importObject('match-object')
				const result = await matchObject.applyReferee({
					match_id: this.matchId,
					position: 'referee'
				})
				
				uni.hideLoading()
				
				if (result.code === 0) {
					uni.showToast({
						title: '申请提交成功',
						icon: 'success'
					})
				} else {
					this.handleError(result.message || '申请提交失败')
				}
			} catch (error) {
				uni.hideLoading()
				this.handleError('网络错误: ' + error.message)
			}
		},
		
		// 获取状态文本
		getStatusText(status) {
			const statusMap = {
				draft: '草稿',
				published: '已发布',
				in_progress: '进行中',
				completed: '已完成',
				cancelled: '已取消'
			}
			return statusMap[status] || status
		},
		
		// 格式化日期
		formatDate(dateString) {
			if (!dateString) return ''
			const date = new Date(dateString)
			return `${date.getMonth() + 1}月${date.getDate()}日`
		},
		
		// 格式化日期范围
		formatDateRange(startDate, endDate) {
			if (!startDate) return ''
			
			const start = new Date(startDate)
			const end = endDate ? new Date(endDate) : null
			
			if (end && start.toDateString() !== end.toDateString()) {
				return `${start.getMonth() + 1}月${start.getDate()}日 - ${end.getMonth() + 1}月${end.getDate()}日`
			} else {
				return `${start.getMonth() + 1}月${start.getDate()}日`
			}
		},
		
		// 格式化比赛赛制，确保显示全汉字
		formatMatchFormat(format) {
			const formatValue = format || '十一人制';
			
			// 统一转换为全汉字格式
			switch(formatValue) {
				case '11人制':
				case '十一人制':
					return '十一人制';
				case '7人制':
				case '七人制':
					return '七人制';
				case '5人制':
				case '五人制':
					return '五人制';
				default:
					return formatValue || '十一人制';
			}
		},
		
		// 格式化裁判需求
		formatRefereeRequirements(requirements) {
			if (!requirements) return '无要求'
			
			// 如果是数字，转换为通用描述
			if (typeof requirements === 'number') {
				if (requirements === 1) {
					return '主裁判1名'
				} else if (requirements === 3) {
					return '主裁判1名、助理裁判2名'
				} else if (requirements === 5) {
					return '主裁判1名、助理裁判2名、第四官员1名、裁判监督1名'
				} else {
					return `需要${requirements}名裁判`
				}
			}
			
			// 如果是数组格式
			if (Array.isArray(requirements)) {
				return requirements.map(req => `${req.position}${req.count}人`).join('、')
			}
			
			// 如果是对象格式
			if (typeof requirements === 'object') {
				const needs = []
				const positionNames = {
					main_referee: '主裁判',
					assistant_referee: '助理裁判',
					fourth_official: '第四官员',
					referee_supervisor: '裁判监督'
				}
				
				Object.keys(requirements).forEach(key => {
					const count = requirements[key]
					if (count > 0) {
						const name = positionNames[key] || key
						needs.push(`${name}${count}名`)
					}
				})
				
				return needs.length > 0 ? needs.join('、') : '无要求'
			}
			
			return String(requirements)
		},
		
		// 错误处理
		handleError(message) {
			uni.showToast({
				title: message,
				icon: 'none'
			})
		},
		
		// 分享相关方法
		showShareModal() {
			if (!this.matchDetail) {
				this.handleError('比赛信息未加载完毕')
				return
			}
			this.showShareModalFlag = true
		},
		
		closeShareModal() {
			this.showShareModalFlag = false
		},
		
		// 处理小程序分享事件
		onShareToMiniProgram(shareContent) {
			// 设置页面的分享数据，供微信小程序调用
			this.shareData = shareContent
			
			// 触发小程序原生分享
			if (typeof wx !== 'undefined' && wx.updateShareMenuData) {
				wx.updateShareMenuData({
					title: shareContent.title,
					path: shareContent.path,
					imageUrl: shareContent.imageUrl,
					success: () => {
						uni.showToast({
							title: '请点击右上角分享',
							icon: 'none'
						})
					}
				})
			} else {
				uni.showToast({
					title: '请点击右上角分享',
					icon: 'none'
				})
			}
		},
		
		// 处理分享触发事件
		onTriggerShare(shareData) {
			console.log('触发分享:', shareData)
			
			// 在微信小程序中，将分享数据设置到页面实例上
			// 这样onShareAppMessage方法就能使用这些数据
			if (shareData.type === 'weixin') {
				this.currentShareData = shareData.content
				
				// 更新页面的分享配置
				this.updateShareConfig(shareData.content)
			}
		},
		
		// 更新分享配置
		updateShareConfig(shareContent) {
			// 将分享数据存储到页面实例上，供onShareAppMessage使用
			this.shareTitle = shareContent.title
			this.sharePath = shareContent.path
			this.shareImageUrl = shareContent.imageUrl
		},
		
		// 分享成功回调
		onShareSuccess(data) {
			console.log('分享成功:', data)
			// 可以在这里记录分享统计数据
		},
		
		// 检查时段是否已完成最终选派确认
		isSlotSelectionFinalized(slot) {
			if (!slot.applications || slot.applications.length === 0) {
				return false
			}
			
			// 如果存在confirmed状态的申请，说明已完成最终选派确认
			return slot.applications.some(app => app.status === 'confirmed')
		},
		
	}
}
</script>

<style lang="scss" scoped>
/* 全局容器样式 */
.detail-container {
	min-height: 100vh;
	background: linear-gradient(180deg, #F8FFFE 0%, #F5F7FA 100%);
	padding-bottom: 40rpx;
}

.ui-test-container {
	min-height: 100vh;
	background: linear-gradient(180deg, #F8FFFE 0%, #F5F7FA 100%);
	padding-bottom: 40rpx;
}

/* 头部信息卡片 */
.competition-header-card {
	background: #FFFFFF;
	margin: 20rpx;
	border-radius: 20rpx;
	padding: 30rpx;
	box-shadow: 0 8rpx 30rpx rgba(67, 207, 124, 0.15);
	border: 2rpx solid rgba(67, 207, 124, 0.1);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.competition-info {
	flex: 1;
}

.competition-title {
	font-size: 36rpx;
	font-weight: 700;
	color: #1A1A1A;
	margin-bottom: 16rpx;
	display: block;
}

.competition-stats {
	display: flex;
	align-items: center;
	gap: 20rpx;
}

.stat-item {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.stat-number {
	font-size: 32rpx;
	font-weight: 700;
	color: #43CF7C;
	line-height: 1;
}

.stat-label {
	font-size: 24rpx;
	color: #666666;
	margin-top: 4rpx;
}

.stat-divider {
	width: 2rpx;
	height: 40rpx;
	background: #E5E5E5;
}

.header-actions {
	display: flex;
	gap: 12rpx;
}

.action-btn {
	display: flex;
	align-items: center;
	gap: 8rpx;
	padding: 16rpx 24rpx;
	border-radius: 16rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 600;
	transition: all 0.3s ease;
	
	&.primary {
		background: linear-gradient(135deg, #43CF7C 0%, #3BC46E 100%);
		box-shadow: 0 4rpx 16rpx rgba(67, 207, 124, 0.4);
	}
	
	&:active {
		transform: scale(0.95);
	}
}

.action-text {
	color: #FFFFFF;
	font-size: 26rpx;
	font-weight: 600;
}

/* 标签切换 */
.tab-switch {
	display: flex;
	margin: 0 20rpx 20rpx 20rpx;
	background: #FFFFFF;
	border-radius: 16rpx;
	padding: 8rpx;
	box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
}

.tab-item {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 20rpx 0;
	border-radius: 12rpx;
	transition: all 0.3s ease;
	
	&.active {
		background: linear-gradient(135deg, #43CF7C 0%, #3BC46E 100%);
		box-shadow: 0 4rpx 12rpx rgba(67, 207, 124, 0.3);
		
		.tab-text {
			color: #FFFFFF;
			font-weight: 600;
		}
	}
}

.tab-text {
	font-size: 28rpx;
	color: #999999;
	transition: all 0.3s ease;
}

/* 日程列表 */
.schedule-list {
	padding: 0 20rpx;
}

.schedule-card {
	background: #FFFFFF;
	border-radius: 20rpx;
	margin-bottom: 24rpx;
	overflow: hidden;
	box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.08);
	border: 2rpx solid rgba(67, 207, 124, 0.1);
	transition: all 0.3s ease;
	
	&:active {
		transform: translateY(-2rpx);
		box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.12);
	}
	
	/* 已结束日程样式 */
	&.schedule-completed {
		opacity: 0.7;
		filter: grayscale(0.3);
		border-color: rgba(180, 180, 180, 0.3);
		
		.date-main {
			background: linear-gradient(135deg, #9E9E9E 0%, #757575 100%);
		}
		
		.weekday, .venue-text {
			color: #999 !important;
		}
		
		.summary-text {
			color: #aaa !important;
		}
		
		.team-name {
			color: rgba(255, 255, 255, 0.8) !important;
		}
		
		.apply-btn {
			opacity: 0.6;
		}
	}
}

.schedule-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 24rpx 30rpx;
	background: linear-gradient(135deg, #F8FFFE 0%, #F0F9F6 100%);
	border-bottom: 2rpx solid rgba(67, 207, 124, 0.1);
}

.date-info {
	display: flex;
	align-items: center;
	gap: 20rpx;
	flex: 1;
}

.date-main {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100rpx;
	height: 100rpx;
	background: linear-gradient(135deg, #43CF7C 0%, #3BC46E 100%);
	border-radius: 20rpx;
	color: #FFFFFF;
	box-shadow: 0 6rpx 20rpx rgba(67, 207, 124, 0.4);
}

.date-number {
	font-size: 36rpx;
	font-weight: 700;
	line-height: 1;
}

.date-month {
	font-size: 24rpx;
	font-weight: 500;
	line-height: 1;
	margin-top: 4rpx;
}

.date-details {
	display: flex;
	flex-direction: column;
	gap: 8rpx;
}

.weekday {
	font-size: 28rpx;
	font-weight: 600;
	color: #1A1A1A;
}

.venue-info {
	display: flex;
	align-items: center;
	gap: 6rpx;
}

.venue-icon {
	font-size: 20rpx;
}

.venue-text {
	font-size: 22rpx;
	color: #666666;
	font-weight: 500;
}

.schedule-summary {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8rpx;
	margin-right: 20rpx;
}

.summary-item {
	display: flex;
	align-items: center;
	gap: 6rpx;
}

.summary-icon {
	font-size: 20rpx;
}

.summary-text {
	font-size: 26rpx;
	font-weight: 600;
	color: #1A1A1A;
}

.schedule-actions {
	display: flex;
	gap: 12rpx;
}

.action-icon {
	min-width: 56rpx;
	height: 56rpx;
	border-radius: 14rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	padding: 0 12rpx;
	
	&.invite {
		background: rgba(0, 122, 255, 0.1);
		&:active {
			background: rgba(0, 122, 255, 0.2);
			transform: scale(0.9);
		}
	}
	
	&.edit {
		background: rgba(67, 207, 124, 0.1);
		&:active {
			background: rgba(67, 207, 124, 0.2);
			transform: scale(0.9);
		}
	}
	
	&.delete {
		background: rgba(255, 59, 48, 0.1);
		&:active {
			background: rgba(255, 59, 48, 0.2);
			transform: scale(0.9);
		}
	}
}

/* 时段容器 */
.time-slots-container {
	padding: 0;
}

.time-slot-wrapper {
	display: flex;
	align-items: center;
	padding: 24rpx 30rpx;
	border-bottom: 2rpx solid rgba(229, 229, 229, 0.5);
	transition: all 0.3s ease;
	
	&:last-child {
		border-bottom: none;
	}
	
	&:active {
		background: rgba(67, 207, 124, 0.03);
	}
	
	/* 已完成选派的时段样式 */
	&.slot-finalized {
		opacity: 0.6;
		background: rgba(240, 240, 240, 0.5);
		
		.team-name {
			color: rgba(255, 255, 255, 0.7) !important;
		}
		
		.category-badge {
			background: rgba(180, 180, 180, 0.3);
			color: #999;
		}
		
		.time-text, .field-text {
			color: #999 !important;
		}
		
		&:active {
			background: rgba(240, 240, 240, 0.5);
		}
	}
}

.left-info {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	min-width: 130rpx;
	margin-right: 16rpx;
}

.time-info {
	
}

.time-text {
	font-size: 24rpx;
	color: #333333;
	font-weight: 600;
	line-height: 1.2;
}

.field-info {
	display: flex;
	align-items: center;
	gap: 6rpx;
}

.field-icon {
	font-size: 18rpx;
}

.field-text {
	font-size: 22rpx;
	color: #666666;
	font-weight: 500;
}

.divider-line {
	width: 2rpx;
	height: 80rpx;
	background: #E5E5E5;
	margin: 0 16rpx 0 0;
}

.right-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.match-info {
	display: flex;
	margin-bottom: 12rpx;
	position: relative;
	height: 72rpx;
	border-radius: 12rpx;
	overflow: hidden;
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
}

.team-section {
	flex: 1;
	position: relative;
	display: flex;
	flex-direction: column;
}

.team-card {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	flex: 1;
	padding: 0;
	color: #FFFFFF;
	font-weight: 600;
	height: 72rpx;
	position: relative;
	border-radius: 12rpx;
}

.home-team-card {
	background: linear-gradient(135deg, #00aff0  0%, #00aff0  100%);
	clip-path: polygon(0% 0%, 100% 0%, 85% 100%, 0% 100%);
	margin-right: -12rpx;
	z-index: 2;
}

.away-team-card {
	background: linear-gradient(135deg, #FF0000 0%, #FF0000 100%);
	clip-path: polygon(15% 0%, 100% 0%, 100% 100%, 0% 100%);
	padding-left: 24rpx;
	z-index: 1;
}

.team-label {
	font-size: 24rpx;
	color: rgba(255, 255, 255, 0.8);
	font-weight: 500;
	position: absolute;
	left: 32rpx;
	top: 50%;
	transform: translateY(-50%);
}

.team-name {
	font-size: 28rpx;
	font-weight: 700;
	color: #FFFFFF;
	line-height: 1;
	text-align: center;
	word-break: keep-all;
	letter-spacing: -0.5rpx;
	white-space: nowrap;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	margin-left: 16rpx;
}

.category-badge {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8rpx 16rpx;
	background: rgba(67, 207, 124, 0.15);
	color: #43CF7C;
	font-size: 26rpx;
	font-weight: 600;
	border-radius: 12rpx;
	height: 44rpx;
	min-width: 80rpx;
	box-sizing: border-box;
	flex-shrink: 0;
}

.bottom-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16rpx;
	min-height: 44rpx;
}

.apply-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6rpx;
	padding: 8rpx 16rpx;
	border-radius: 12rpx;
	transition: all 0.3s ease;
	height: 44rpx;
	min-width: 80rpx;
	box-sizing: border-box;
	flex-shrink: 0;
	
	&.available {
		background: linear-gradient(135deg, #43CF7C 0%, #3BC46E 100%);
		box-shadow: 0 4rpx 12rpx rgba(67, 207, 124, 0.3);
	}
	
	&.applied {
		background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
		box-shadow: 0 4rpx 12rpx rgba(52, 199, 89, 0.3);
	}
	
	&.finalized {
		background: linear-gradient(135deg, #8E8E93 0%, #6C6C70 100%);
		box-shadow: 0 4rpx 12rpx rgba(142, 142, 147, 0.3);
		cursor: not-allowed;
		
		&:active {
			transform: none;
		}
	}
	
	&:active {
		transform: scale(0.95);
	}
}

.apply-text {
	font-size: 26rpx;
	color: #FFFFFF;
	font-weight: 600;
}

.apply-icon {
	font-size: 30rpx;
	font-weight: 700;
}

.slot-notes {
	display: flex;
	align-items: flex-start;
	gap: 8rpx;
	margin-top: 12rpx;
	padding: 8rpx 0;
}

.notes-text {
	font-size: 20rpx;
	color: #FF9500;
	line-height: 1.4;
	flex: 1;
}

/* 意向岗位信息样式 */
.preferred-positions {
	display: flex;
	align-items: flex-start;
	gap: 8rpx;
	margin-top: 12rpx;
	padding: 8rpx 16rpx;
	background: rgba(67, 207, 124, 0.1);
	border-radius: 8rpx;
	border-left: 4rpx solid #43CF7C;
}

.preferred-icon {
	font-size: 20rpx;
	line-height: 1.4;
	flex-shrink: 0;
}

.preferred-text {
	font-size: 20rpx;
	color: #43CF7C;
	line-height: 1.4;
	flex: 1;
	font-weight: 600;
}

/* 空状态 */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 120rpx 40rpx;
}

.empty-title {
	font-size: 32rpx;
	color: #999999;
	margin-top: 24rpx;
	font-weight: 500;
}

.empty-subtitle {
	font-size: 26rpx;
	color: #CCCCCC;
	margin-top: 12rpx;
}

/* 图标样式 */
.action-icon .icon-text, .tab-icon, .venue-icon, 
.time-icon, .field-icon, .referee-icon, .count-icon, 
.apply-icon, .notes-icon, .empty-icon {
	font-size: 32rpx;
	line-height: 1;
}

.action-icon.invite .icon-text {
	font-size: 24rpx;
	font-weight: 600;
	color: #007AFF;
}

.icon-text {
	font-size: 24rpx;
	font-weight: 600;
}

.tab-icon {
	font-size: 28rpx;
}

.venue-icon, .time-icon, .field-icon, .referee-icon, 
.count-icon, .notes-icon {
	font-size: 24rpx;
}

.apply-icon {
	font-size: 30rpx;
	font-weight: 700;
}

.empty-icon {
	font-size: 160rpx;
	color: #E5E5E5;
	margin-bottom: 24rpx;
}

/* 加载状态 */
.loading-container {
	padding: 40rpx;
	display: flex;
	justify-content: center;
}

/* 详情标签页样式 */
.detail-tab {
	background: linear-gradient(180deg, #F8FFFE 0%, #F5F7FA 100%);
	min-height: 100vh;
	padding: 20rpx;
}

.detail-content {
	background: linear-gradient(180deg, #F8FFFE 0%, #F5F7FA 100%);
	min-height: 100vh;
	padding-bottom: 40rpx;
}

/* 比赛详情卡片样式 */
.match-header,
.info-card,
.description-card,
.referee-card {
	background: #FFFFFF;
	border-radius: 20rpx;
	padding: 30rpx;
	margin-bottom: 20rpx;
	box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.08);
}



.title-section {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 20rpx;
}

.match-title {
	flex: 1;
	font-size: 36rpx;
	font-weight: bold;
	color: #333;
	line-height: 1.4;
}

.match-status {
	padding: 8rpx 16rpx;
	border-radius: 20rpx;
	font-size: 24rpx;
	color: #fff;
	margin-left: 20rpx;
	
	&.status-draft {
		background-color: #999;
	}
	
	&.status-published {
		background-color: #1BAE76;
	}
	
	&.status-in_progress {
		background-color: #ff9500;
	}
	
	&.status-completed {
		background-color: #007aff;
	}
	
	&.status-cancelled {
		background-color: #ff3b30;
	}
}

.organizer-section {
	display: flex;
	flex-direction: column;
	gap: 12rpx;
}

.organizer-info,
.contact-info {
	display: flex;
	align-items: center;
	gap: 12rpx;
}

.organizer-text,
.contact-text {
	font-size: 28rpx;
	color: #666;
}

/* 删除重复的info-card样式定义 */

.card-title {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-bottom: 30rpx;
}

.title-text {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
}

.info-grid {
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}

.info-item {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
}

.info-label {
	font-size: 28rpx;
	color: #666;
	width: 200rpx;
	flex-shrink: 0;
}

.info-value {
	flex: 1;
	font-size: 28rpx;
	color: #333;
	text-align: right;
}

.description-text {
	font-size: 28rpx;
	color: #333;
	line-height: 1.6;
}

.referee-list {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.referee-item {
	padding: 20rpx;
	background-color: #f8f9fa;
	border-radius: 12rpx;
}

.position-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12rpx;
}

.position-name {
	font-size: 28rpx;
	font-weight: bold;
	color: #333;
}

.position-count {
	font-size: 26rpx;
	color: #1BAE76;
}

.requirements-text {
	font-size: 26rpx;
	color: #666;
}



.bottom-actions {
	position: fixed;
	bottom: 60rpx; /* 调整位置，避免挡住手机功能键 */
	left: 0;
	right: 0;
	display: flex;
	gap: 20rpx;
	padding: 30rpx 40rpx; /* 增加内边距 */
	background-color: #fff;
	border-top: 2rpx solid #f0f0f0;
	box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1); /* 添加阴影 */
}

.share-bottom-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10rpx;
	padding: 24rpx 32rpx; /* 减小按钮高度 */
	background: #f8f9fa;
	border: 2rpx solid #e0e0e0;
	color: #666;
	border-radius: 16rpx;
	font-size: 28rpx; /* 稍微调小字体 */
	font-weight: 500;
	transition: all 0.3s ease;
	min-height: 88rpx; /* 设置最小高度确保一致性 */
	
	&:active {
		transform: scale(0.95);
		background: #e9ecef;
	}
}

.share-bottom-text {
	color: #666;
	font-size: 28rpx; /* 与按钮字体一致 */
	line-height: 1;
}

.apply-bottom-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #1BAE76 0%, #16a085 100%);
	color: white;
	border: none;
	border-radius: 16rpx;
	padding: 0; /* 移除padding，使用min-height控制高度 */
	font-size: 40rpx; /* 进一步增大字体 */
	font-weight: bold;
	box-shadow: 0 4rpx 16rpx rgba(27, 174, 118, 0.3);
	transition: all 0.3s ease;
	min-height: 88rpx; /* 与分享按钮保持一致的高度 */
	line-height: 1; /* 确保文字垂直居中 */
	
	&:active {
		transform: scale(0.98);
		box-shadow: 0 2rpx 8rpx rgba(27, 174, 118, 0.4);
	}
}







/* 职位选择弹窗样式 */
.position-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.position-modal {
	width: 90%;
	max-width: 600rpx;
	max-height: 80vh;
	background: white;
	border-radius: 20rpx;
	overflow: hidden;
	box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	background: linear-gradient(135deg, #1BAE76 0%, #16a085 100%);
	color: white;
}

.modal-title {
	font-size: 32rpx;
	font-weight: bold;
}

.close-btn {
	width: 60rpx;
	height: 60rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	font-size: 28rpx;
	cursor: pointer;
}

.modal-content {
	padding: 30rpx;
	max-height: 60vh;
	overflow-y: auto;
}

.position-tip {
	margin-bottom: 30rpx;
	padding: 20rpx;
	background: #fff3cd;
	border-radius: 12rpx;
	border-left: 6rpx solid #ffc107;
}

.tip-text {
	font-size: 24rpx;
	color: #856404;
	line-height: 1.4;
}

/* 简洁职位列表样式 */
.position-simple-list {
	display: flex;
	flex-direction: column;
	gap: 12rpx;
	margin-bottom: 30rpx;
}

.position-simple-item {
	padding: 20rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 12rpx;
	background: white;
	transition: all 0.3s ease;
	cursor: pointer;
}

.position-simple-item:active {
	transform: scale(0.98);
}

.position-simple-item.applied {
	border-color: #1BAE76;
	background: #f0fff4;
}

.position-simple-item.selected {
	border-color: #1BAE76;
	background: #e6f7ff;
	box-shadow: 0 0 0 2rpx rgba(27, 174, 118, 0.2);
}

.position-simple-item.manage-mode {
	border-color: #ff6b6b;
}

.position-simple-item.manage-mode:hover {
	border-color: #ff6b6b;
	box-shadow: 0 4rpx 12rpx rgba(255, 107, 107, 0.2);
}

.position-simple-item.manage-mode.selected {
	border-color: #ff6b6b;
	background: #ffe6e6;
	box-shadow: 0 0 0 2rpx rgba(255, 107, 107, 0.3);
}

.position-simple-item.disabled {
	opacity: 0.5;
	background: #f5f5f5;
	border-color: #ddd;
	cursor: not-allowed;
}

.position-simple-item.disabled:active {
	transform: none;
}

.position-simple-item.disabled .applied-badge-text {
	color: #999;
}

.position-content {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.position-text {
	font-size: 28rpx;
	color: #333;
	font-weight: 500;
}

.applied-badge {
	display: flex;
	align-items: center;
	gap: 12rpx;
}

.applied-badge-text {
	font-size: 24rpx;
	color: #1BAE76;
	font-weight: 500;
}

.cancel-simple-btn {
	padding: 6rpx 16rpx;
	background: #ff6b6b;
	color: white;
	border: none;
	border-radius: 16rpx;
	font-size: 20rpx;
}

/* 统一手机号输入区域 */
.phone-section {
	margin-bottom: 30rpx;
	background: #f8f9fa;
	border-radius: 16rpx;
	padding: 24rpx;
}

.phone-label-row {
	margin-bottom: 16rpx;
}

.phone-label {
	font-size: 28rpx;
	color: #333;
	font-weight: 600;
}

.phone-unified-input {
	width: 100%;
	padding: 30rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 12rpx;
	font-size: 30rpx;
	background: white;
	transition: all 0.3s ease;
	box-sizing: border-box;
	min-height: 88rpx;
}

.phone-unified-input:focus {
	border-color: #1BAE76;
	box-shadow: 0 0 0 4rpx rgba(27, 174, 118, 0.1);
}

/* 确认报名按钮 */
.confirm-section {
	margin-top: 20rpx;
}

.confirm-apply-btn {
	width: 100%;
	padding: 24rpx 0;
	background: linear-gradient(135deg, #1BAE76 0%, #16a085 100%);
	color: white;
	border: none;
	border-radius: 12rpx;
	font-size: 32rpx;
	font-weight: bold;
	transition: all 0.3s ease;
}

.confirm-apply-btn:disabled {
	background: #ccc;
	color: #999;
	cursor: not-allowed;
}

.confirm-apply-btn:not(:disabled):active {
	transform: scale(0.98);
}

.confirm-cancel-btn {
	width: 100%;
	padding: 24rpx 0;
	background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
	color: white;
	border: none;
	border-radius: 12rpx;
	font-size: 32rpx;
	font-weight: bold;
	transition: all 0.3s ease;
}

.confirm-cancel-btn:disabled {
	background: #ccc;
	color: #999;
	cursor: not-allowed;
}

.confirm-cancel-btn:not(:disabled):active {
	transform: scale(0.98);
}

.modal-footer {
	padding: 20rpx 30rpx;
	border-top: 2rpx solid #f0f0f0;
	background: #fafafa;
}

.close-modal-btn {
	width: 100%;
	padding: 20rpx 0;
	background: #f5f5f5;
	color: #666;
	border: none;
	border-radius: 12rpx;
	font-size: 26rpx;
}

.detail-content {
	background: linear-gradient(180deg, #F8FFFE 0%, #F5F7FA 100%);
	min-height: 100vh;
	padding-bottom: 40rpx;
}

/* 比赛详情卡片样式 */
.match-header,
.info-card,
.description-card,
.referee-card {
	background: #FFFFFF;
	border-radius: 20rpx;
	padding: 30rpx;
	margin-bottom: 20rpx;
	box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.08);
}



.empty-text {
	margin-top: 20rpx;
	font-size: 28rpx;
	color: #999;
}

.empty-tip {
	margin-top: 10rpx;
	font-size: 24rpx;
	color: #ccc;
}

.schedule-tab {
	background-color: #f5f5f5;
	min-height: 100vh;
	padding: 20rpx;
}

.competition-header-card {
	background: #fff;
	border-radius: 16rpx;
	padding: 30rpx;
	margin-bottom: 20rpx;
	box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
}

.competition-info {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.competition-title {
	font-size: 36rpx;
	font-weight: bold;
	color: #333;
}

.competition-stats {
	display: flex;
	align-items: center;
	gap: 40rpx;
}

.stat-item {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.stat-number {
	font-size: 40rpx;
	font-weight: bold;
	color: #333;
}

.stat-label {
	font-size: 24rpx;
	color: #666;
}

.stat-divider {
	width: 2rpx;
	height: 40rpx;
	background: #e0e0e0;
}

.tab-switch {
	display: flex;
	background: #fff;
	border-radius: 16rpx;
	padding: 16rpx;
	margin-bottom: 20rpx;
	box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
}

.tab-item {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 16rpx;
	border-radius: 8rpx;
	
	&.active {
		background: #f0f0f0;
		
		.tab-text {
			color: #333;
			font-weight: bold;
		}
	}
}

.tab-icon {
	font-size: 32rpx;
}

.tab-text {
	font-size: 28rpx;
	color: #666;
}



/* 补充缺失的基础样式 */
.error-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 100rpx 0;
}

.error-text {
	margin-top: 20rpx;
	font-size: 28rpx;
	color: #999;
}

.retry-btn {
	margin-top: 20rpx;
	background-color: #1BAE76;
	color: white;
	border: none;
	border-radius: 8rpx;
	padding: 12rpx 30rpx;
	font-size: 28rpx;
}

/* 原有的详情页面样式 */
.title-section {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 20rpx;
}

.match-title {
	flex: 1;
	font-size: 36rpx;
	font-weight: bold;
	color: #333;
	line-height: 1.4;
}

.match-status {
	padding: 8rpx 16rpx;
	border-radius: 20rpx;
	font-size: 24rpx;
	color: #fff;
	margin-left: 20rpx;
	
	&.status-draft {
		background-color: #999;
	}
	
	&.status-published {
		background-color: #1BAE76;
	}
	
	&.status-in_progress {
		background-color: #ff9500;
	}
	
	&.status-completed {
		background-color: #007aff;
	}
	
	&.status-cancelled {
		background-color: #ff3b30;
	}
}

.organizer-section {
	display: flex;
	flex-direction: column;
	gap: 12rpx;
}

.organizer-info,
.contact-info {
	display: flex;
	align-items: center;
	gap: 12rpx;
}

.organizer-text,
.contact-text {
	font-size: 28rpx;
	color: #666;
}

.card-title {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-bottom: 30rpx;
}

.title-text {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
}

.info-grid {
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}

.info-item {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
}

.info-label {
	font-size: 28rpx;
	color: #666;
	width: 200rpx;
	flex-shrink: 0;
}

.info-value {
	flex: 1;
	font-size: 28rpx;
	color: #333;
	text-align: right;
}

.description-text {
	font-size: 28rpx;
	color: #333;
	line-height: 1.6;
}

.referee-list {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.referee-item {
	padding: 20rpx;
	background-color: #f8f9fa;
	border-radius: 12rpx;
}

.position-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12rpx;
}

.position-name {
	font-size: 28rpx;
	font-weight: bold;
	color: #333;
}

.position-count {
	font-size: 26rpx;
	color: #1BAE76;
}

.requirements-text {
	font-size: 26rpx;
	color: #666;
}

.bottom-actions {
	position: fixed;
	bottom: 60rpx;
	left: 0;
	right: 0;
	display: flex;
	gap: 20rpx;
	padding: 30rpx 40rpx;
	background-color: #fff;
	border-top: 2rpx solid #f0f0f0;
	box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
}

.share-bottom-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10rpx;
	padding: 24rpx 32rpx;
	background: #f8f9fa;
	border: 2rpx solid #e0e0e0;
	color: #666;
	border-radius: 16rpx;
	font-size: 28rpx;
	font-weight: 500;
	transition: all 0.3s ease;
	min-height: 88rpx;
	
	&:active {
		transform: scale(0.95);
		background: #e9ecef;
	}
}

.share-bottom-text {
	color: #666;
	font-size: 28rpx;
	line-height: 1;
}

/* 职位选择弹窗样式 */
.position-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.position-modal {
	width: 90%;
	max-width: 600rpx;
	max-height: 80vh;
	background: white;
	border-radius: 20rpx;
	overflow: hidden;
	box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	background: linear-gradient(135deg, #1BAE76 0%, #16a085 100%);
	color: white;
}

.modal-title {
	font-size: 32rpx;
	font-weight: bold;
}

.close-btn {
	width: 60rpx;
	height: 60rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	font-size: 28rpx;
	cursor: pointer;
}

.modal-content {
	padding: 30rpx;
	max-height: 60vh;
	overflow-y: auto;
}

.position-tip {
	margin-bottom: 30rpx;
	padding: 20rpx;
	background: #fff3cd;
	border-radius: 12rpx;
	border-left: 6rpx solid #ffc107;
}

.tip-text {
	font-size: 24rpx;
	color: #856404;
	line-height: 1.4;
}

.position-simple-list {
	display: flex;
	flex-direction: column;
	gap: 12rpx;
	margin-bottom: 30rpx;
}

.position-simple-item {
	padding: 20rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 12rpx;
	background: white;
	transition: all 0.3s ease;
	cursor: pointer;
}

.position-simple-item:active {
	transform: scale(0.98);
}

.position-simple-item.applied {
	border-color: #1BAE76;
	background: #f0fff4;
}

.position-simple-item.selected {
	border-color: #1BAE76;
	background: #e6f7ff;
	box-shadow: 0 0 0 2rpx rgba(27, 174, 118, 0.2);
}

.position-content {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.position-text {
	font-size: 28rpx;
	color: #333;
	font-weight: 500;
}

.applied-badge {
	display: flex;
	align-items: center;
	gap: 12rpx;
}

.applied-badge-text {
	font-size: 24rpx;
	color: #1BAE76;
	font-weight: 500;
}

.phone-section {
	margin-bottom: 30rpx;
	background: #f8f9fa;
	border-radius: 16rpx;
	padding: 24rpx;
}

.phone-label-row {
	margin-bottom: 16rpx;
}

.phone-label {
	font-size: 28rpx;
	color: #333;
	font-weight: 600;
}

.phone-unified-input {
	width: 100%;
	padding: 30rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 12rpx;
	font-size: 30rpx;
	background: white;
	transition: all 0.3s ease;
	box-sizing: border-box;
	min-height: 88rpx;
}

.phone-unified-input:focus {
	border-color: #1BAE76;
	box-shadow: 0 0 0 4rpx rgba(27, 174, 118, 0.1);
}

.confirm-section {
	margin-top: 20rpx;
}

.confirm-apply-btn {
	width: 100%;
	padding: 24rpx 0;
	background: linear-gradient(135deg, #1BAE76 0%, #16a085 100%);
	color: white;
	border: none;
	border-radius: 12rpx;
	font-size: 32rpx;
	font-weight: bold;
	transition: all 0.3s ease;
}

.confirm-apply-btn:disabled {
	background: #ccc;
	color: #999;
	cursor: not-allowed;
}

.confirm-apply-btn:not(:disabled):active {
	transform: scale(0.98);
}

.modal-footer {
	padding: 20rpx 30rpx;
	border-top: 2rpx solid #f0f0f0;
	background: #fafafa;
}

.close-modal-btn {
	width: 100%;
	padding: 20rpx 0;
	background: #f5f5f5;
	color: #666;
	border: none;
	border-radius: 12rpx;
	font-size: 26rpx;
}

/* 日程已结束标签 */
.schedule-completed-tag {
	position: absolute;
	top: -8rpx;
	right: -8rpx;
	padding: 4rpx 8rpx;
	border-radius: 8rpx;
	font-size: 18rpx;
	color: #fff;
	background: linear-gradient(135deg, #8E8E93 0%, #6C6C70 100%);
	font-weight: 600;
	box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.2);
	border: 1rpx solid rgba(255, 255, 255, 0.3);
	z-index: 2;
}

/* 新时段标记 */
.new-slots-badge {
	padding: 6rpx 12rpx;
	border-radius: 12rpx;
	font-size: 20rpx;
	color: #fff;
	background: linear-gradient(135deg, #FF6B6B 0%, #FF5252 100%);
	font-weight: 600;
	box-shadow: 0 2rpx 8rpx rgba(255, 107, 107, 0.3);
	margin-bottom: 8rpx;
	display: inline-block;
	animation: new-badge-pulse 2s infinite;
}

/* 操作区域包装器 */
.schedule-actions-wrapper {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8rpx;
}

/* 新时段动画效果 */
@keyframes new-badge-pulse {
	0% {
		transform: scale(1);
		opacity: 1;
	}
	50% {
		transform: scale(1.05);
		opacity: 0.8;
	}
	100% {
		transform: scale(1);
		opacity: 1;
	}
}

/* 已完成的日期主体样式 */
.date-completed {
	position: relative;
	
	.date-number, .date-month {
		color: rgba(255, 255, 255, 0.9) !important;
	}
}
</style> 